package cn.enited.devtools.apiaggregator.dto;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.data.domain.Page;

@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Accessors(chain = true)
public class PageActionResult<T> extends ActionResult {
    private static final long serialVersionUID = -9020816696072757056L;

    private Page<T> data;

    public PageActionResult(int code, String message, Page<T> data) {
        super(code, message);
        this.data = data;
    }

    public PageActionResult() {
        this.data = Page.empty();
    }

    public PageActionResult(int code, String message) {
        super(code, message);
        this.data = Page.empty();
    }

    public static <T> PageActionResult<T> of(int code, String message, Page<T> data) {
        return new PageActionResult<>(code, message, data);
    }
}
